package org;

import org.simplecrm.domain.customer.Customer;
import org.simplecrm.repository.customer.CustomerDAO;
import org.simplecrm.repository.customer.CustomerJdbcDAO;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class SpringDAOApp {

    private SpringDAOApp() {
    }

    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

        CustomerDAO customerDAO = context.getBean("customerDAO", CustomerJdbcDAO.class);

        List<Customer> customers = customerDAO.getAllCustomers();
        for (Customer customer : customers) {
            System.out.println(customer.toString());
        }

    }
}
